<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <title>MyBlog-Login</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--====== Favicon Icon ======-->
    <link rel="shortcut icon" href="assets/images/favicon.png" type="image/png">
    <!--====== Bootstrap CSS ======-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <!--====== SignIn CSS ======-->
    <link rel="stylesheet" href="assets/css/signin.css">
</head>

<body style="background-color: whitesmoke">
<!--====== 从这里开始 ======-->
<form class="form-signin" id="form">
    <div style="text-align: center">
        <img class="mb-4" src="assets/images/signin/blog-icon.png" alt="" width="72" height="72">
    </div>
    <h3 class="mb-3 font-weight-normal" style="text-align: center">请登录...</h3>
    <label for="username" class="sr-only">Username</label>
    <input type="text" id="username" class="form-control" placeholder="username" required autofocus>
    <label for="inputPassword" class="sr-only">Password</label>
    <input type="password" id="inputPassword" class="form-control" placeholder="password" required>
    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="loginSubmit()">登录</button>
    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="toReg()" style="margin-top: 0px">注册</button>
    <div class="mb-3">
        <a href="/blog_view/blog.html"> 游客登录，请点击这里</a><br>
        <a href="/blog_view/forget-password.html"> 忘记密码</a>
    </div>
    <div style="text-align: center">
        <p class="mt-5 mb-3 text-muted">&copy; 2018-2020</p>
    </div>
</form>

<!--====== 从这里结束 ======-->


<!--====== 自定义代码结束 ======-->


<!--导入所有js文件-->
<!--====== Jquery js ======-->
<script src="assets/js/vendor/jquery-1.12.4.min.js"></script>
<!--====== Bootstrap js ======-->
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/util/HttpUtil.js"></script>
</body>
</html>
<script type="text/javascript">
    function loginSubmit(){
        let username = $("#username").val();
        let password = $("#inputPassword").val();
        if (username=="" || password==""){
            alert("所有项都不能为空");
            return;
        }
        let  url="login.do";
        let params = {username: username, password: password};
        doPost(url,params,function () {
            location.href = "http://localhost:8080/blog_view/index2.html";
        })
    }
    function toReg() {
        location.href = "http://localhost:8080/blog_view/register.html";
    }
</script>